import 'package:flutter/material.dart';
import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';

import '../tool/assets.dart';

class UnitBar extends StatefulWidget {
  final String title;
  final List<GroupModel> groupList;
  const UnitBar({super.key, required this.title, required this.groupList});

  @override
  State<UnitBar> createState() => _UnitBarState();
}

class _UnitBarState extends State<UnitBar> {
  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      mainAxisSize: MainAxisSize.max,
      children: widget.groupList.map(($0) {
        return Expanded(
            child: IconButton(
                splashColor: Colors.transparent,
                highlightColor: Colors.transparent,
                onPressed: () {
                  setState(() {
                    globalController.chooseGroup(widget.groupList, $0, widget.title);
                  });
                },
                padding: EdgeInsets.zero, //,
                iconSize: 20,
                icon: Image.asset($0.select ? assets.connect : assets.connect_dis)));
      }).toList(),
    );
  }
}
